<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./vue.js"></script>
    <style>
      .active {
        color: orange;
        background-color: black;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <!-- prevent阻止浏览器默认行为 -->
      <a href="http://www.baidu.com" @click.prevent>百度</a>
      <div @click="num++">
        <!-- stop 阻止冒泡 -->
        <button @click.stop>{{num}}</button>
      </div>
      <!-- self    this==e.target -->
      <div @click.self="num++">
        <button>{{num}}</button>
      </div>
      <!-- 组合键 -->
      <button @click.ctrl="num++" @click.alt="num--" @click.shift="num=500">
        {{num}}
      </button>
      <!-- 回车 -->
      <input type="text" @keyup.enter="tip" />
    </div>
  </body>
  <script>
    let { createApp } = Vue;
    // 创建Vue根实例
    let app = createApp({
      data() {
        return {
          num: 100,
        };
      },
      methods: {
        tip() {
          alert("回车");
        },
      },
    });
    app = app.mount("#app"); //指定容器
  </script>
</html>
